import { loginAPI } from '@/api/user'
import { setToken, getToken, removeToken } from '@/utils/auth'
export default {
  namespaced: true,
  state: {
    token: getToken() || ''
  },
  mutations: {
    updatetokedn(state, newtoken) {
      state.token = newtoken
      setToken(newtoken)
    },
    removetoken(state) {
      state.token = ''
      removeToken()
    }
  },
  actions: {
    async loginaction(store, obj) {
      const res = await loginAPI(obj)
      // console.log(res.data.token)
      store.commit('updatetokedn', res.data.token)
    }
  },
  getters: {}
}
